<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>建设单位信息管理</title>
	<script src="../../js/header.js"></script>
	<style type="text/css">
		html, body, #jscompanymessage {
			padding: 0px;
			margin: 0px;
			/*height: 100%;*/
		}
		#jscompanymessage{
			border-top: 3px solid #0D9AFF;
			padding: 25px;
			/*background-attachment: fixed;*/
			/*overflow: hidden;*/
		}
		.tab-title{
			font-size: 16px;
			font-weight: bold;
			border-left: 4px solid #0D9AFF;
			font-family: PingFangSC-Medium;
			padding-left:10px;
			margin-bottom: 20px;
		}
		.el-dialog__footer {
			padding: 10px 20px 20px;
			text-align: center;
			-webkit-box-sizing: border-box;
			box-sizing: border-box;
		}
		.el-dialog__body {
			color: rgb(96, 98, 102);
			font-size: 14px;
			word-break: break-all;
			padding: 0px 20px;
		}
		#excel {
			display: none;
		}
		.el-input__inner {
			-webkit-appearance: none;
			background-color: #FFF;
			background-image: none;
			border-radius: 4px;
			border: 1px solid #DCDFE6;
			-webkit-box-sizing: border-box;
			box-sizing: border-box;
			color: #606266;
			display: inline-block;
			font-size: inherit;
			height: 30px;
			line-height: 30px;
			outline: 0;
			padding: 0 15px;
			-webkit-transition: border-color .2s cubic-bezier(.645,.045,.355,1);
			transition: border-color .2s cubic-bezier(.645,.045,.355,1);
		}
		/*#jscompanymessage .el-input,
		#jscompanymessage .el-select,
		#jscompanymessage .el-input-number{
			width: 100%;
		}*/
		.listed .el-form-item__label{
			letter-spacing: 3px;
		}
		.el-textarea {
			width: 95%;
		}

		/* 搜索按钮样式修改 */
		#jscompanymessage .el-button.is-circle.search_btn{
			position: absolute;
			right: 0;
			top: 0;
			border: 0;
			background: none;
		}
		#jscompanymessage .el-button.is-circle.search_btn i{
			font-size: 17px;
		}
	</style>
</head>

<body>
<div v-cloak id="jscompanymessage">
	<div style="margin-top: 10px;">
		<div style="margin-top: 10px;border-bottom:1px solid rgba(200,200,200,0.43);">
			<el-form :model="selectForm" :rules="rules" ref="selectForm" label-width="150px">
				<el-row>
					<el-col :span="6">
						<el-form-item label="单位名称:" prop="" label-width="110px">
							<el-input v-model="selectForm.entName" placeholder="" ></el-input>
						</el-form-item>
					</el-col>
					<el-col span="6">
						<el-form-item label="统一社会信用代码:">
							<el-row>
								<el-form-item prop="">
									<el-input v-model="selectForm.uniscid" placeholder="" ></el-input>
								</el-form-item>
							</el-row>
						</el-form-item>
					</el-col>
					<el-col :span="10">
						<el-form-item label="企业成立时间:" prop="" label-width="160px">
							<el-row>
								<el-col span="9" style="width: 180px;">
									<el-form-item prop="startTime">
										<el-date-picker
												v-model="selectForm.startTime"
												type="date"
												value-format="yyyy-MM-dd"
												placeholder="选择开始时间"
												style="width: 180px;">
										</el-date-picker>
									</el-form-item>
								</el-col>
								<el-col span="1" style="color: rgb(192, 204, 218);text-align: center;">
									<span>—</span>
								</el-col>
								<el-col :span="5" style="">
									<el-form-item prop="endTime">
										<el-date-picker
												v-model="selectForm.endTime"
												type="date"
												value-format="yyyy-MM-dd"
												placeholder="选择结束时间"
												style="width: 180px;">
										</el-date-picker>
									</el-form-item>
								</el-col>
							</el-row>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row style="margin-bottom: 30px;">
					<div style="float: right;">
						<el-button v-if="hasApprovalBtn" type="primary" size="small" style="width: 60px;height: 30px;" @click="apply()">申请</el-button>
						<el-button type="primary" size="small" style="width: 60px;height: 30px;" @click="searchForm('selectForm')">查询</el-button>
						<el-button type="warning" size="small" style="width: 60px;height: 30px;" @click="resetForm('selectForm')">重置</el-button>
					</div>
				</el-row>
			</el-form>
		</div>

		<el-table :data="tableData" border style="width: 100%;margin-top: 35px;" :header-cell-style="{background:'#eef1f6',color:'#606266'}">
			<!--<el-table-column type="selection" ></el-table-column>-->
			<el-table-column
					prop="entName"
					label="单位名称"
					width="250"
					:show-overflow-tooltip="true"
					align="center" >
			</el-table-column>
			<el-table-column
					prop="uniscid"
					label="统一社会信用代码"
					width="300"
					align="center">
			</el-table-column>
			<el-table-column
					prop="location"
					label="企业所在地"
					width="250"
					align="center">
			</el-table-column>
			<el-table-column
					prop="establishTime"
					label="企业成立时间"
					width="140"
					align="center">
			</el-table-column>
			<el-table-column
					prop="legalPerson"
					label="企业法人"
					width="120"
					align="center">
			</el-table-column>
			<el-table-column
					label="操作"
					width=""
					align="center">
				<template slot-scope="scope">
					<el-button type="" size="mini" @click="view(scope.$index,scope.row)">查看</el-button>
					<el-button v-if="hasApprovalBtn" type="primary" size="mini" @click="edit(scope.$index,scope.row)">修改</el-button>
					<el-button v-if="hasApprovalBtn" type="danger" size="mini" @click="del(scope.$index,scope.row)">删除</el-button>
				</template>
			</el-table-column>
		</el-table>
		<div style="overflow: hidden;">
			<div class="pagination">
				<el-pagination
						@size-change="handleSizeChange"
						@current-change="handleCurrentChange"
						:current-page="currentPage"
						:page-sizes="[10, 20, 30, 40]"
						:page-size="pagesize"
						background
						layout="total, sizes,prev, pager, next"
						:total="tableTotal"
						prev-text="上一页"
						next-text="下一页">
				</el-pagination>
			</div>
		</div>
		<!--建设单位页面-->
		<el-dialog title="" :visible.sync="dialogForm" center fullscreen>
			<div style="margin-top: 10px;">
				<el-form :model="constructionUnitEntity" :rules="rules" ref="constructionUnitEntity" label-width="140px">
					<el-row>
						<el-col :span="4" class="tab-title">
							基本信息
						</el-col>
					</el-row>
					<el-row>
						<el-col :span="7">
							<el-form-item label="用户名:"  prop="userName" label-width="110px">
								<el-input v-model="constructionUnitEntity.userName"  placeholder="" autoComplete="off" :disabled="userDisabled"></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7">
							<el-form-item label="密码:" prop="password" label-width="190px">
								<el-input v-model="constructionUnitEntity.password"  placeholder="" show-password auto-complete="new-password" :disabled="userDisabled"></el-input>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row>
						<el-col :span="7">
							<el-form-item label="企业名称:"  prop="entName" label-width="110px">
								<el-input v-model="constructionUnitEntity.entName"  placeholder="" :disabled="formDisabled"></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7">
							<el-form-item label="统一社会信用代码:" prop="uniscid" label-width="190px">
								<el-input v-model="constructionUnitEntity.uniscid" placeholder="" :disabled="formDisabled"></el-input>
							</el-form-item>
						</el-col>
					</el-row>


					<el-row>
						<el-col :span="10">
							<el-form-item label="企业所在地:" v-model="constructionUnitEntity.location"  prop="location" label-width="110px">
								<el-select v-model="provinceValue" placeholder="请选择省" @change="chooseProvince" style="width: 150px;" :disabled="formDisabled">
									<el-option
											v-for="item in provinceData"
											:key="item.code"
											:label="item.name"
											:value="item.name">
									</el-option>
								</el-select>
								<span style="color: #C0CCDA;;">—</span>
								<el-select v-model="cityValue" placeholder="请选择市" @change="chooseCity" style="width: 150px;" :disabled="formDisabled">
									<el-option
											v-for="item in cityData"
											:key="item.code"
											:label="item.name"
											:value="item.name">
									</el-option>
								</el-select>
								<span style="color: #C0CCDA;;">—</span>
								<el-select v-model="areaValue" @change="chooseArea" placeholder="请选择区、县" style="width: 150px;" :disabled="formDisabled">
									<el-option
											v-for="item in areaData"
											:key="item.code"
											:label="item.name"
											:value="item.name">
									</el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="9">
							<el-form-item label="企业详细地址:"  prop="detailedAddr" label-width="110px">
								<el-input v-model="constructionUnitEntity.detailedAddr" placeholder="" :disabled="formDisabled"></el-input>
							</el-form-item>
						</el-col>
						<el-col span="5">
							<el-form-item label="邮编:"  prop="postalCode" label-width="90px">
								<el-input v-model="constructionUnitEntity.postalCode" style="width: 200px;" placeholder="" :disabled="formDisabled"></el-input>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row>
						<el-col :span="4">
							<el-form-item label="企业法人:" prop="legalPerson"  label-width="110px">
								<el-input v-model="constructionUnitEntity.legalPerson" placeholder="" :disabled="formDisabled"></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="企业性质:" prop="entType" label-width="110px">
								<el-select  v-model="constructionUnitEntity.entType" placeholder="请选择" :disabled="formDisabled" style="width: 250px;">
									<el-option label="上市企业" value="1"></el-option>
									<el-option label="上市企业控股" value="2"></el-option>
									<el-option label="上市企业参股" value="3"></el-option>
									<el-option label="国有企业" value="4"></el-option>
									<el-option label="国有企业控股" value="5"></el-option>
									<el-option label="国有企业参股" value="6"></el-option>
									<el-option label="其他" value="7"></el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="企业成立时间:"  prop="establishTime" label-width="110px">
								<el-date-picker type="date" placeholder="选择日期" v-model="constructionUnitEntity.establishTime" :disabled="formDisabled" style="width: 250px;">
								</el-date-picker>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row>
						<!--<el-col span="8">
                            <el-form-item label="上市情况:" prop="fileName" label-width="100px" class="listed">
                                <el-radio-group v-model="radio2">
                                    <el-radio :label="3">境外上市</el-radio>
                                    <el-radio :label="6">境内上市</el-radio>
                                    <el-radio :label="9">否</el-radio>
                                </el-radio-group>
                            </el-form-item>
                        </el-col>-->
					</el-row>
					<el-row>
						<el-col :span="4">
							<el-form-item label="联系人:" prop="linkMan" label-width="110px">
								<el-input v-model="constructionUnitEntity.linkMan" placeholder="" :disabled="formDisabled"></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="联系电话:"  prop="linkTel" label-width="110px">
								<el-input v-model="constructionUnitEntity.linkTel" placeholder="" :disabled="formDisabled" style="width: 250px;" ></el-input>
							</el-form-item>
						</el-col>
						<el-col span="6">
							<el-form-item label="企业邮箱:" prop="email" label-width="110px">
								<el-input v-model.trim="constructionUnitEntity.email" placeholder="" :disabled="formDisabled" style="width: 250px;"></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="办公电话:" prop="bgTel" label-width="290px">
								<el-input v-model="constructionUnitEntity.bgTel"  placeholder="" :disabled="formDisabled"  style="width: 200px;"></el-input>
							</el-form-item>
						</el-col>
					</el-row>
				<!--	<el-row>
						<el-col :span="10">
							<el-form-item label="办公电话:" style="letter-spacing: 4px;" prop="bgTel" label-width="110px">
								<el-input v-model="constructionUnitEntity.bgTel" style="width: 500px;" placeholder="" :disabled="formDisabled"></el-input>
							</el-form-item>
						</el-col>
					</el-row>-->
						<el-row>
							<el-col span="22">
								<el-form-item label="营业执照上传:"prop="fujian" label-width="110px">
									<!--<el-input v-model="constructionUnitEntity.businessLicense" style="width: 180px;" placeholder="不超过5M"></el-input>
                                    <input type="file" id="excel" ref="head" accept="" @change="checkType()" enctype="multipart/form-data"/>
                                    <el-button  size="small" style="width:75px;height: 30px;background: #E5E9F2;border-radius: 4px;color: #0D9AFF;" @click="selectFile()">选择文件</el-button>-->
									<iframe id="newFrame" style="overflow:hidden;height:200px;width:100%;" frameBorder="0"
											:src="link2"></iframe>
									<!--style="overflow:hidden;height:40vh;width:100%;" width="100%"-->
								</el-form-item>
							</el-col>
						</el-row>
					<el-row>
						<el-col :span="22">
							<el-form-item label="企业资质附件:" prop="fujian" label-width="110px">
								<!--<el-input v-model="constructionUnitEntity.fileName" style="width: 180px;" placeholder=""></el-input>
                                <input type="file" id="excel"ref="head" accept="" @change="checkType()" enctype="multipart/form-data"/>
                                <el-button  size="small" style="width:75px;height: 30px;background: #E5E9F2;border-radius: 4px;color: #0D9AFF;" @click="selectFile()">选择文件</el-button>-->
								<iframe id="viewFrame" style="overflow:hidden;height:200px;width:100%;" width="100%" frameBorder="0"
										:src="link"></iframe>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row>
						<el-col :span="22">
							<div style="float:right;">
								<el-button v-show="showOnSubmit" type="primary" size="small" style="width: 60px;height: 30px;" @click="submitForm('constructionUnitEntity')">提交</el-button>
								<el-button v-show="showOnReplace" type="primary" size="small" style="width: 60px;height: 30px;" @click="onReplace()">修改</el-button>
								<el-button type="info" size="small" style="width: 60px;height: 30px;" @click="dialogForm = false;">关闭</el-button>
							</div>
						</el-col>
					</el-row>
				</el-form>

			</div>
		</el-dialog>
	</div>
</div>
<script>
    var vm = new Vue({
        el: '#jscompanymessage',
        data() {
            // 验证手机号是否合法
            let checkMobile = (rule, value, callback) => {
                if (!checkIphon(value) && value != '') {
                    callback(new Error('手机号码不合法'));
                } else {
                    callback();
                }
            };
            // 验证邮箱是否合法
            let checkEmail = (rule, value, callback) => {
                if (!this.isEmail(value) && value != '') {
                    callback(new Error('邮箱不合法'));
                } else {
                    callback();
                }
            };
            // 验证用户名是否合法
            let checkUserName = (rule, value, callback) => {
                if(!isUserName(value) && value != '') {
                    callback(new Error('用户名必须为字母、数字或下划线!'));
                } else {
                    callback();
                }
            };
            // 验证密码是否合法
            let checkPassword = (rule, value, callback) => {
                if(!isPassword(value) && value != "") {
                    callback(new Error('密码必须为字母或数字!'));
                } else {
                    callback();
                }
            };
            return {
                uuid:'',
                link:'',//iframe链接
                link2:'',//iframe链接
                currentPage: 1, //默认显示页面为1
                pagesize: 10, // 每页的数据条数
                tableTotal:'',
                radio2:6,
                constructionUnitEntity : {
                    id:"",
                    entName: "",
                    uniscid: "",
                    location:"",
                    businessLicense: "",
                    detailedAddr: "",
                    establishTime: "",
                    password:'',
                    postalCode: "",
                    legalPerson: "",
                    entType: "",
                    linkTel: "",
                    linkMan: "",
                    email: "",
                    bgTel: "",
                    userName : ""
                },
                provinceValue:'',
                cityValue:'',
                areaValue:'',
                provinceData: [],
                cityData: [],
                areaData: [],
                formDisabled: false,
                userDisabled: false,
                moveInDisabled: false,
                moveOutDisabled: false,
                rules: {
                    entName: [{
                        required: true,
                        message: '请输入企业名称',
                        trigger: 'blur'
                    },{
                        max : 500,
                        message : '长度最大为500个字符',
                        trigger : 'blur'
                    }],
                    uniscid: [{
                        required: true,
                        message: '请输入统一社会信用代码',
                        trigger: 'blur'
                    },{
                        max : 500,
                        message : '长度最大为500个字符',
                        trigger : 'blur'
                    }],
                    userName: [{
                        required: true,
                        message: '请输入用户名',
                        trigger: 'blur'
                    },{
                        min : 2,
                        max : 50,
                        message : '用户名长度必须在2-50个字符',
                        trigger : 'blur'
                    },{
                        validator : checkUserName,
                        message : '用户名必须为字母、数字或下划线',
                        trigger : 'blur'
                    }],
                    location: [{
                        required: true,
                        message: '请输入企业所在地',
                        trigger: 'blur'
                    },{
                        max : 500,
                        message : '长度最大为500个字符',
                        trigger : 'blur'
                    }],
                    password: [{
                        required: true,
                        message: '请输入密码',
                        trigger: 'blur'
                    },{
                        min: 6,
                        message: '密码不小于6位',
                        trigger: 'blur'
                    },{
                        max : 500,
                        message : '长度最大为500个字符',
                        trigger : 'blur'
                    }],
                    legalPerson: [{
                        required: true,
                        message: '请输入企业法人',
                        trigger: 'blur'
                    },{
                        max : 500,
                        message : '长度最大为500个字符',
                        trigger : 'blur'
                    }],
                    postalCode: [{
                        min: 6,
                        max: 6,
                        message: '邮编格式不正确',
                        trigger: 'blur'
                    },{
                        max : 500,
                        message : '长度最大为500个字符',
                        trigger : 'blur'
                    }],
                    entType: [{
                        required: true,
                        message: '请选择企业性质',
                        trigger: 'blur'
                    },{
                        max : 500,
                        message : '长度最大为500个字符',
                        trigger : 'blur'
                    }],
                    linkMan: [{
                        required: true,
                        message: '请输入联系人',
                        trigger: 'blur'
                    },{
                        max : 500,
                        message : '长度最大为500个字符',
                        trigger : 'blur'
                    }],
                    linkTel: [{
                        required: true,
                        message: "请输入联系电话",
                        trigger: 'blur'
                    },{
                        validator: checkMobile,
                        message: '联系电话不合法',
                        trigger: 'blur'
                    },{
                        max : 500,
                        message : '长度最大为100个字符',
                        trigger : 'blur'
                    }],
                    email: [{
                        validator: checkEmail,
                        message: '企业邮箱不合法',
                        trigger: 'blur'
                    },{
                        max : 500,
                        message : '长度最大为500个字符',
                        trigger : 'blur'
                    }],
                    detailedAddr : [{
                        max : 500,
                        message : '长度最大为500个字符',
                        trigger : 'blur'
                    }],
                    bgTel : [{
                        max : 200,
                        message : '长度最大为200个字符',
                        trigger : 'blur'
                    }]

                },
                dialogFormVisible: false,
                dialogForm: false,
                formInline: {
                    enterpriseName: ''
                },
                selectForm: {
                    entName: '',
                    uniscid: '',
                    startTime: '',
                    endTime: ''
                },
                companyInformation: [],
                currentRow: null,
                tableData: [],
                showOnSubmit: true,
                showOnReplace: false,
                hasApprovalBtn:true
            }
        },
        created(){
            var userInfo = JSON.parse(localStorage.getItem('userInfo'));
            var userRole = userInfo.orgName;
            if(userRole.includes("建设单位")){
                this.hasApprovalBtn = false;
            }
            axios.get('../../json/ChinaCity.json').then(res=>{
                this.provinceData = res.data;
            }).catch(e => {
                this.$message.error("网络连接超时");
            })
        },
        mounted(){
            this.getData();
        },
        methods: {
            getData() {
                var pagesize = this.pagesize;
                var pageno = this.currentPage;
                axios({
                    method: 'get',
                    url: '/dzjap/constr/listpage',
                    params: {
                        pageSize: pagesize,
                        pageNo: pageno,
                        entName: this.selectForm.entName,
                        uniscid: this.selectForm.uniscid,
                        startTime: this.selectForm.startTime,
                        endTime: this.selectForm.endTime,
                    }
                })
				.then(response => {
					let data = response.data;
					if (data.code == 200) {
						let dataInformation = data.page.results;
						this.tableTotal = data.page.total;// 数据长度

						this.tableData = dataInformation;

					} else {
						this.$message.error(data.msg);
					}
				})
				.catch(function (error) {
					console.log(error);
				});
            },
            //获取UUID的方法
            getUuid() {
                axios({
                    method: 'get',
                    url: '/dzjap/uuid/getUuid',
                })
                    .then(response => {
                        console.log(response);
                        if (response.data.code == 200) {
                            this.uuid = response.data.data;
                            this.link="../upload/annex.html?uuid="+this.uuid+"&flag=1";
                            this.link2="../upload/annex.html?uuid="+this.uuid+"yyzz"+"&flag=1";
                            console.log(this.uuid);
                        } else {
                            this.$message.error(response.data.msg);
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            // 表单提交
            onSubmit() {
                this.$refs[constructionUnitEntity].validate((valid) => {
                    if (valid) {
                        this.constructionUnitEntity.id = this.uuid;
                        axios({
                            method: 'post',
                            url: 'enterPrise/addEnterPrise',
                            data: this.constructionUnitEntity
                        })
                            .then((response) => {
                                let data = response.data;
                                if (data.code == 200) {
                                    this.dialogForm = false;
                                    this.$message({
                                        type: 'success',
                                        message: '添加成功!'
                                    });
                                    this.getData();
                                } else {
                                    this.$message.error(data.msg);
                                }
                            });
                    }
                })
            },
            // 表单修改
            onReplace(){
                this.$refs['constructionUnitEntity'].validate((valid) => {
                    if (valid) {
                        axios({
                            method: 'post',
                            url: '/dzjap/constr/update',
                            data: this.constructionUnitEntity
                        })
                            .then((response) => {
                                let data = response.data;
                                if (data.code == 200) {
                                    this.dialogForm = false;
                                    this.$message({
                                        type: 'success',
                                        message: '修改成功!'
                                    });
                                    this.getData();
                                } else {
                                    this.$message.error(data.msg);
                                }
                            });
                    }
                })
            },
            clearForm(){
                this.showMoveOutList = false;
                this.showMoveInList = false;
                
                /*this.$nextTick(()=>{
                	this.$refs['constructionUnitEntity'].resetField();
                })*/
                this.clearFromInformation();
            },
            // 清空表单
            clearFromInformation(){
                this.constructionUnitEntity.entName = "";
				this.constructionUnitEntity.location ="";
				this.constructionUnitEntity.businessLicense = "";
				this.constructionUnitEntity.detailedAddr = "";
				this.constructionUnitEntity.establishTime = "";
				this.constructionUnitEntity.userName = "";
				this.constructionUnitEntity.password ='';
				this.constructionUnitEntity.postalCode = "";
				this.constructionUnitEntity.legalPerson = "";
				this.constructionUnitEntity.entType = "";
				this.constructionUnitEntity.linkTel = "";
				this.constructionUnitEntity.linkMan = "";
				this.constructionUnitEntity.email = "";
				this.constructionUnitEntity.bgTel = "";
				this.constructionUnitEntity.uniscid ="";
                this.provinceValue ='';
                this.cityValue ='';
                this.areaValue ='';
            },
            handleChange(value) {
                console.log(value);
            },
            apply(){
                this.dialogForm = true;
                this.showOnSubmit = true;
                this.showOnReplace = false;

                this.clearForm();
                this.getUuid();
                this.formDisabled = false;
                this.userDisabled = false;
            },
            /* 单选搜索表单 */
            selectCurrentChange(val){
                this.currentRow = val;
            },
            /* 列表页搜索 */
            searchForm(selectForm) {
                var pagesize = this.pagesize;
                var pageno = this.currentPage;

                axios({
                    method: 'get',
                    url:  '/dzjap/constr/listpage',
                    params: {
                        pageSize: pagesize,
                        pageNo: pageno,
                        entName: this.selectForm.entName,
                        uniscid: this.selectForm.uniscid,
                        startTime: this.selectForm.startTime,
                        endTime: this.selectForm.endTime,
                    }
                })
                .then(response => {
                    let data = response.data;
                    if (data.code == 200) {
                        let dataInformation = response.data.page.results;
                        this.tableTotal = response.data.page.total;// 数据长度

                        this.tableData = dataInformation;
                    } else {
                        this.$message.error(data.msg);
                    }
                })
                .catch(function (error) {
                    console.log(error);
                });
            },
            /* 列表页重置 */
            resetForm() {
                this.selectForm.entName = '';
				this.selectForm.uniscid = '';
				this.selectForm.location = '';
				this.selectForm.establishTime = '';
				this.selectForm.legalPerson = '';
                this.selectForm.startTime='';
                this.selectForm.endTime='';
           		/*this.$nextTick(() => {
               		this.$refs['selectForm'].resetField();
               	})*/

                this.getData();
            },
            //每页下拉显示数据
            handleSizeChange(size) {
                this.pagesize = size;
                this.getData();
                /*console.log(this.pagesize) */
            },
            //点击第几页
            handleCurrentChange(currentPage) {
                this.currentPage = currentPage;
                this.getData();
            },
            // 设置允许填写和不允许填写
            checkDisabled(n){
                if(n){
                    this.formDisabled = true;
                }else{
                    this.formDisabled = false;
                }
            },
            // 删除
            del(index,row){
                this.$confirm('确定要删除吗?', '提示', {
                    cancelButtonText: '取消',
                    confirmButtonText: '确定',
                    type: 'warning'
                }).then(() => {
                    axios({
                        method: 'post',
                        url: '/dzjap/constr/delConstr/'+row.id,
                    })
                        .then(response => {
                            let data = response.data;
                            console.log(response)
                            if (data.code == 200) {
                                // 确认删除
                                this.$message({
                                    type: 'success',
                                    message: '删除成功!'
                                });
                                this.getData();
                            } else {
                                this.$message.error(data.msg);
                            }
                        })
                        .catch(function (error) {
                            console.log(error);
                        });
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '取消删除'
                    });
                });
            },
            // 查看
            view(index,row){
                this.uuid=row.id;
                this.link="../upload/annex.html?uuid="+this.uuid+"&flag=0";
                this.link2="../upload/annex.html?uuid="+this.uuid+"yyzz"+"&flag=0";
                this.dialogForm = true;
                this.showOnReplace = false;
                this.showOnSubmit = false;
                this.showOnJoinList = false;
				this.formDisabled=true;
				this.userDisabled = true;
                this.showInformation(index,row);
                this.checkDisabled(true);
            },
            // 修改
            edit(index,row){
                this.uuid=row.id;
                this.link="../upload/annex.html?uuid="+this.uuid+"&flag=1";
                this.link2="../upload/annex.html?uuid="+this.uuid+"yyzz"+"&flag=1";
                this.dialogForm = true;
                this.showOnReplace = true;
                this.showOnSubmit = false;
                this.showOnJoinList = false;

                this.showInformation(index,row);
                
                this.checkDisabled(false);
                this.userDisabled = true;
            },
            // 公共方法--查看
            showInformation(index,row){
                axios({
                    method: 'post',
                    url: '/dzjap/constr/findbyid/'+row.id,
                })
				.then(response => {
					let data = response.data;
					if (data.code == 200) {
						let rowdata = data.constructionUnitEntity;
						// this.clearForm(); // 重置
                        var arr = rowdata.location.split("-");
                        this.provinceValue = arr[0];
                        this.cityValue = arr[1];
                        this.areaValue = arr[2];
						this.constructionUnitEntity = rowdata;
						axios.get('../../json/ChinaCity.json').then(res=>{
		                	this.provinceData = res.data;
		                    this.provinceData.map(e=>{//遍历数据
			                    if( this.provinceValue == e.name){
				                    this.cityData = e.cityList;
				                    this.cityData.map(e=>{//遍历数据
					                    if( this.cityValue == e.name){
						                    this.areaData = e.areaList;
						                    return;
						                }
						            })
				                    return;
				                }
				            })
						}).catch(e => {
							this.$message.error("网络连接超时");
						})
					} else {
						this.$message.error(data.msg);
					}
				})
				.catch(function (error) {
					console.log(error);
				});
            },
            submitForm() {
                this.$refs['constructionUnitEntity'].validate((valid) => {
                    if (valid) {
                        this.constructionUnitEntity.id = this.uuid;
                        var encrypt = new JSEncrypt();
                        encrypt.setPublicKey(publicKey);
                        let result = encrypt.encrypt(this.constructionUnitEntity.password);
                        this.constructionUnitEntity.password = result;
                        axios({
                            method: 'post',
                            url: '/dzjap/construct/regist',
                            data: this.constructionUnitEntity,
                        })
                            .then(response => {
                                let data = response.data;
                                if (data.code == 200) {
                                    this.dialogForm = false;
                                    this.clearForm();

                                    this.$message({
                                        message: '注册成功',
                                        type: 'success'
                                    });
                                    this.getData();
                                } else {
                                    this.$message.error(data.msg);
                                }
                            })
                            .catch(function (error) {
                                console.log(error);
                            });
                    }
                })
            },
            chooseProvince(value){
                this.cityValue = '';
                this.areaValue = '';
                this.cityData = [];
                this.areaData = [];
                this.provinceData.map(e=>{//遍历数据
                    if( value == e.name){
                        this.cityData = e.cityList;
                        return;
                    }
                })
                console.log(value)
                this.constructionUnitEntity.location = value;
            },
            chooseCity(value){
                this.areaValue = '';
                this.cityData.map(e=>{//遍历数据
                    if( value == e.name){
                        this.areaData = e.areaList;
                        return;
                    }
                })
                this.constructionUnitEntity.location=this.constructionUnitEntity.location +"-" +value;
                console.log(this.constructionUnitEntity.location)
            },
            chooseArea(value){
                this.constructionUnitEntity.location=this.constructionUnitEntity.location +"-" +value;
            },
            //检查上传类型
            checkType() {
                let vm = this;
                let allImgExt = '.xls|.xlsx|';
                let filePath = this.$refs.head.value;
                let extName = filePath.substring(filePath.lastIndexOf(".")).toLowerCase();
                if (allImgExt.indexOf(extName + '|') === -1) {
                    this.$message("请选择正确的Excel文件");
                    this.$refs.head.value = '';
                    excelContent = [];
                    return;
                }
                let file = this.$refs.head.files[0];
                this.selectForm.fileName = file.name;

            },
            //选取文件
            selectFile(){
                this.$refs.head.click();
            },
            // 验证字符串是否为邮箱
            isEmail(str) {
                let re = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/
                if (re.test(str)) {
                    return true;
                } else {
                    return false;
                }
            }
        }
    })
</script>
</body>
</html>